// This code is hosted on http://code.google.com/p/lenthorp/
// Freely available for use in applications, but should NOT be modified
// Email all comments to lenthorpresearch@gmail.com

#ifndef quantlib_tradingengines_longstrategy_hpp
#define quantlib_tradingengines_longstrategy_hpp

#include <qt/tradingengine.hpp>


namespace QuantLib {


	// Here the strategy is very simple - just buy at the beginning and sell at the end, no other entry/exit conditions
	class LongStrategy : public TradingStrategy {

		public:

			LongStrategy(std::string longAssetName) {
					_assetNamesMap["mainAssetName"] = longAssetName;
			}
			
			std::vector<TradeOrder> getAction(Portfolio& p) {
				std::vector<TradeOrder> orders = std::vector<TradeOrder>();
				if (p.isAllCash()) {
					Real assetPrice = _assetAnalytics.getCurrentAssetValue(p, _assetNamesMap["mainAssetName"]);
					orders.push_back(TradeOrder(TradeOrder::OrderType::buy, static_cast<Size>((Real)(p.getAvailableCash()) / assetPrice), _assetNamesMap["mainAssetName"]));
				}
				
				return orders;
			}

	};
}


#endif